var lastresult = true;
var zjname = "";

$("#outerdiv").hide();
$("#Material").hide();
function imgShow(outerdiv, bigimg, _this) {
    var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
    $("#outerdiv").attr("display", "block");
    $("#bigimg").attr("src", src);  //设置#bigimg元素的src属性
    $("#outerdiv").fadeIn("fast");

    $("#outerdiv").click(function () {//再次点击淡出消失弹出层
        $(this).fadeOut("fast");
    });
}


var vm = new Vue({
    el : "#Vehicle",
    data : {
    },
    init:function(){
        var _self = this;
        layui.use(['layer'], function(){
            layer = layui.layer;
        });
    },
    methods: {
        getPhotoByCode: function(event){
            var _self = this;
            var PhotoIds = document.getElementById("PhotoId").value;   //作业工单RFID

            if (event && (event.keyCode != 13 || !(PhotoIds && PhotoIds.length > 0))) {
                return;
            }

            _self.$nextTick(function() {
                _self.$http.post("../../Vehicle/getVehicleLists",{PhotoCode:PhotoIds},{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.CarListsLeft = res.body.PhotoListsLeft;
                        _self.CarListsRight = res.body.PhotoListsRight;
                        _self.result = res.body.result;
                        if(res.body.PhotoListsLeft.length == 0 && res.body.PhotoListsRight.length == 0){
                            _self.vueAlert("无RFID信息！");
                            return;
                        }
                        if(_self.CarListsLeft[0].STATUSS != 'FINISHED' || _self.CarListsRight[0].STATUSS != 'FINISHED'){
                            _self.vueAlert("上道工序未完工！");
                            return;
                        }
                        if(_self.CarListsLeft[0].ZYSTATUS == 'FINISHED' || _self.CarListsRight[0].ZYSTATUS == 'FINISHED' ){
                            _self.vueAlert("该工序已完工！");
                            return;
                        }
                        if(_self.result == 'false'){
                            _self.vueAlert("该工单对应夹板库存不足！");
                            return;
                        }
                        var equipmentwork = "";
                        var equipmentworks = "";
                        var cuttingTitle = "";

                        cuttingTitle += "<div class=\"layui-form-item\"; style='border-bottom:1px solid #000'>";
                        cuttingTitle +="<span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>工单号: "+_self.CarListsLeft[0].ZYCODE+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        cuttingTitle +="<span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>型体: "+_self.CarListsLeft[0].WLNAME+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        /*cuttingTitle +="<span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>夹板: "+_self.CarListsLeft[0].JBNAME+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";*/
                        cuttingTitle +="<span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>鞋面颜色: "+_self.CarListsLeft[0].YSNAME+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        cuttingTitle += "<div class=\"layui-form-item\">";


                         equipmentwork += "<div class=\"layui-form-item\">";
                        for( i = 0 ; i<res.body.PhotoListsLeft.length ; i++){

                            if(_self.CarListsLeft[i].LEFTIMG != null){
                                equipmentwork +="<div class='layui-inline' style=\"display:inline-block;\" >  " ;

                                equipmentwork +="<div class='layui-col-xs4' class='div_card'>" ;
                                equipmentwork +="<div class='layui-row' >";
                                equipmentwork +="<div style='width:300px;float:left;' id ='outerdiv'>";

                                equipmentwork +="<img id=\"bigimg\" src='" + host + "file?id="+_self.CarListsLeft[i].LEFTIMG+"'   style=\"margin-top:10px;\" class=\"div_card_image\" name='"+i+"' >";
                                equipmentwork +="<br/><span style='margin-left:60px; font-weight:bold;'>"+ _self.CarListsLeft[i].BWNAME+"</span>";
                                equipmentwork +="</div>";
                                equipmentwork +="</div>";

                                equipmentwork +="</div>";
                                equipmentwork +="</div>";
                            }

                        }

                        equipmentwork +="</div>";


                            equipmentworks +="<div class='layui-inline'  style=\"display:inline-block; margin-left:10px; float:left;\" >  " ;
                                equipmentworks +="<div style=\"float:right;margin-left:200px;\">";
                                equipmentworks +="<div class=\"div_card_name\">左脚信息</div>";
                        equipmentworks +="<span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>尺码: "+_self.CarListsLeft[0].SIZECODE+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        equipmentworks +="<br><span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>夹板: "+_self.CarListsLeft[0].JBNAME+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        equipmentworks +="<div ></div>";
                                equipmentworks +="</div>";
                            equipmentworks +="</div>";

                        $("#cuttingPhoto").html(equipmentwork);
                        $("#cuttingPhotos").html(equipmentworks);
                        $("#cuttingTitle").html(cuttingTitle);


                        //右脚
                        var rightFoot = "";
                        var rightFoots = "";

                        rightFoot += "<div class=\"layui-form-item\">";
                        for( i = 0 ; i<res.body.PhotoListsRight.length ; i++){

                            if(_self.CarListsRight[i].RIGHTIMG != null) {
                                rightFoot += "<div class='layui-inline' style=\"display:inline-block;\" >  ";

                                rightFoot += "<div class='layui-col-xs4' class='div_card'>";
                                rightFoot += "<div class='layui-row' >";
                                rightFoot += "<div style='width:300px;float:left;' id ='outerdiv'>";
                                rightFoot += "<img id=\"bigimg\" src='" + host + "file?id=" + _self.CarListsRight[i].RIGHTIMG + "'   style=\"margin-top:10px;\" class=\"div_card_image\" name='" + i + "' >";
                                rightFoot += "<br/><span style='margin-left:60px; font-weight:bold;'>" + _self.CarListsRight[i].BWNAME + "</span>";
                                rightFoot += "</div>";
                                rightFoot += "</div>";

                                rightFoot += "</div>";
                                rightFoot += "</div>";
                            }
                        }

                        rightFoot +="</div>";


                        rightFoots +="<div class='layui-inline'  style=\"display:inline-block; margin-left:10px; float:left;\" >  " ;
                        rightFoots +="<div style=\"float:right;margin-left:200px;\">";
                        rightFoots +="<div class=\"div_card_name\">右脚信息</div>";
                        rightFoots +="<span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>尺码: "+_self.CarListsRight[0].SIZECODE+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        rightFoots +="<br><span style='background:#FFFFFF;  margin-top:30px; font-size : 18px; '>夹板: "+_self.CarListsRight[0].JBNAME+" </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        rightFoots +="<div ></div>";
                        rightFoots +="</div>";
                        rightFoots +="</div>";

                        $("#rightFoot").html(rightFoot);
                        $("#rightFoots").html(rightFoots);

                        layui.use(['form'], function(){
                            window.setTimeout(function() {
                                form = layui.form;
                                form.render(); //这个很重要
                            }, 1000);

                        });

                        // _self.showDocument();
                    }

                    $("img").mouseover(function(){
                        $(this).css("cursor","pointer");
                    });

                    $("img").click(function(){
                        var _this = $(this);//将当前的pimg元素作为_this传入函数
                        imgShow("#outerdiv", "#bigimg", _this);
                    });
                });
            });


        }
        ,reset: function(data){
            window.location.reload();
        }
        ,vueAlert: function(msg){
            layui.use(['form'], function(){
                var layer = layui.layer;
                layer.msg(msg,{icon:6,time:2000});
            });
        }
        ,clearReceiveForm: function(){
            $("#reMakeNum").val('');
            $("#confirmReceiveNum").val('');
        },
        // 显示指导文件
        showDocument: function() {
            layer.open({
                type: 2,
                title: '工艺指导文件',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                content: "../../script/js/pdfJs/web/viewer.html?file=../../../../manNeedleCart/downFile/" + this.order //iframe的url
            });
        },
        // 异常上报
        abnormalReport: function() {
            layer.open({
                type: 2,
                title: '异常上报',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                content: "abnormalReport.html" //iframe的url
            });
        }


    }
});
